package com.aiti.lulian.controller;

import com.aiti.base.core.base.controller.WebController;
import com.aiti.base.core.utils.message.Message;
import com.aiti.lulian.dto.CardTemplateStyleFieldDto;
import com.aiti.lulian.entity.CardTemplateStyleField;
import com.aiti.lulian.service.CardTemplateStyleFieldService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/cardTemplateStyleField")
public class CardTemplateStyleFieldController extends WebController {

    @Autowired
    private CardTemplateStyleFieldService cardTemplateStyleFieldService;

    @PostMapping
    public Message save(@RequestBody CardTemplateStyleField entity) {
        return cardTemplateStyleFieldService.saveField(entity);
    }

    @PutMapping
    public Message update(@RequestBody CardTemplateStyleField entity) {
        return cardTemplateStyleFieldService.updateField(entity);
    }

    @DeleteMapping("/{id}")
    public Message delete(@PathVariable String id) {
        return cardTemplateStyleFieldService.deleteField(id);
    }

    @GetMapping("/{id}")
    public Message getById(@PathVariable String id) {
        return cardTemplateStyleFieldService.detail(id);
    }

    @GetMapping("/page")
    public Message page(CardTemplateStyleFieldDto dto) {
        Page page = startPage(dto);
        return cardTemplateStyleFieldService.fieldList(page, dto);
    }

    @DeleteMapping("/deleteByTemplate")
    public Message deleteByTemplate(@RequestParam String templateId) {
        return cardTemplateStyleFieldService.deleteFieldByTemplate(templateId);
    }

    @GetMapping("/fieldListNoRequired")
    public Message fieldListNoRequired(CardTemplateStyleFieldDto dto){
        return cardTemplateStyleFieldService.fieldListNoRequired(dto);
    }


}